package com.example.football.service;

import com.example.football.dao.NewskeyDao;
import com.example.football.dao.PeopleliketeamDao;
import com.example.football.pojo.Newskey;
import com.example.football.pojo.Peopleliketeam;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class NewskeyServiceImpl implements NewskeyService{
    @Resource
    private NewskeyDao sd;

    @Override
    public List<Newskey> queryAll() {

        return sd.selectAll();
    }

    @Override
    public void removeByNewskeyid(Integer id) {
        try {
            sd.deleteByNewskeyid(id);
        } catch (Exception e) {
            throw new RuntimeException("根据ID删除有异常");
        }
    }

    @Override
    public List<Newskey> queryByNewskey(String keyz) {

        return sd.selectByNewskey(keyz);
    }

    @Override
    public Newskey queryById(Integer id) {

        return sd.selectById(id);
    }

    @Override
    public void addNewskey(Newskey newskey) {
        try {
            sd.insertNewskey(newskey);
        } catch (Exception e) {
            throw new RuntimeException("添加有异常");
        }
    }

    @Override
    public void changeNewskey(Newskey newskey) {
        try {
            sd.updateNewskey(newskey);
        } catch (Exception e) {
            throw new RuntimeException("修改数据异常");
        }
    }
}
